// navbar.js
// 获取应用实例
const App = getApp();
const {store} = App
import { setUserInfo } from '../../utils/store';

Component({
  useStore: true,
  properties: {
    title:{
      type: String,
      value: '',
      observer: function (e) {
        console.log('e',e)
        this.setData({ title: e })

      }
    },
    isSowArrow:{
      type: Boolean,
      value: false,
      observer: function (e) {
        console.log('e',e)
        this.setData({ isSowArrow: e })

      }
      
    },
    height:{
      type: String,
      value: '',
      observer: function (e) {
        setTimeout(() => {
          if(e){
            console.log('e',e)
  
            this.setData({ navbarHeight: e })
          }
        }, 100)

        
      }
    }
  },
  data:{
    capsuleTop: '', //胶囊距离屏幕顶部的距离
    capsuleHeight: '', //胶囊高度
    navbarHeight: '', //导航栏高度
    store,
    userInfo:store.getState().userInfo,

    title:'',
    isSowArrow:false
  },
  
  lifetimes: {
    attached: function () {
      this.setData({
        capsuleTop: App.globalData.capsule.top, 
        capsuleHeight: App.globalData.capsule.height, 
        navbarHeight: (App.globalData.capsule.top - App.globalData.system.statusBarHeight) * 2 + App.globalData.capsule.height + App.globalData.system.statusBarHeight +120, 
      
      })
      console.log((App.globalData.capsule.top - App.globalData.system.statusBarHeight) * 2 + App.globalData.capsule.height + App.globalData.system.statusBarHeight +100)
     }
  },
  methods: {
    handleGoToBack(){
      wx.navigateBack({
        delta: 1
      })
    },

    goBacktoHome(){
      wx.reLaunch({
        url: '/pages/bigMenu/bigMenu',
      })
    },

    logout(){
      setUserInfo("");
      wx.reLaunch({
        url: '/pages/login/index',
      })
    }
  }
})
